﻿<basics:ChildWindow xmlns:inputToolkit1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"  
                    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"  
                    xmlns:Toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
                    xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
                    xmlns:src="clr-namespace:ibba.src.norisk"
	                xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
		            xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
                    x:Class="ibba.src.norisk.PageDetalheParametroContrato"
	                HorizontalAlignment="Center" 
	                VerticalAlignment="Center" 
		            Height="490" Width="660" 
		            Title="Detalhes do parâmetro"
                    Background="#FF5C7590">

    <basics:ChildWindow.Resources>
        <src:ConverterNumericUpDown x:Key="ConverterNUD" />
        <src:ConverterTypeCheckBox x:Key="ConverterCHK" />
        <src:ConverterValueCheckBox x:Key="ConverterValueCHK" />
        <src:ConverterDefaultCheckBox x:Key="ConverterDefaultCHK" />
        <src:ConverterValueTextBox x:Key="ConverterValueTxtBox" />
        <src:ConverterTextBox x:Key="ConverterTxtBox" />
        <src:ConverterComboBox x:Key="ConverterCboBox" />
        <src:ConverterDateTime x:Key="ConverterDateTime" />
        <src:ConverterReadonly x:Key="ConverterReadonly"/>
    </basics:ChildWindow.Resources>

    <Grid HorizontalAlignment="Stretch" 
          Background="{x:Null}"
		  VerticalAlignment="Stretch" >

        <Toolkit:BusyIndicator x:Name="activity">

            <Grid x:Name="LayoutRoot" Margin="0,8,0,0">
                <!--<Rectangle Height="43" HorizontalAlignment="Left" Margin="6,262,0,0" Name="rectangle1" Stroke="#FF4545BA" StrokeThickness="12" VerticalAlignment="Top" Width="551" RadiusY="12" RadiusX="12" Style="{StaticResource DividerStyle}" Fill="#FF4545BA" IsHitTestVisible="True" />-->

                <TextBlock 
        			x:Name="txtLabContrato" 
        			Text="Contrato:" 
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="0,8,235,0" 
        			VerticalAlignment="Top" Width="auto" 
        			HorizontalAlignment="Right" FontFamily="Verdana" d:LayoutOverrides="VerticalAlignment" 
				/>

                <TextBlock 
        			x:Name="txtContrato" 
        			Text="Contrato" 
        			FontSize="10"
        			Foreground="#FFFADE88"
        			Margin="0,8,19,0" 
        			VerticalAlignment="Top" Width="212" 
        			HorizontalAlignment="Right" FontFamily="Verdana" d:LayoutOverrides="VerticalAlignment"  FontWeight="Bold" 
				/>

                <TextBlock x:Name="txtLabCliente"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="0,8,587,0"
        			VerticalAlignment="Top" Width="auto" FontFamily="Verdana" 
        			Text="Cliente:" HorizontalAlignment="Right" RenderTransformOrigin="0.897,0.583"	/>

                <TextBlock 
        			x:Name="txtCliente" 
        			Text="Cliente" 
        			FontSize="10"
        			Foreground="#FFFADE88"
        			Margin="64,8,315,0" 
        			VerticalAlignment="Top" FontFamily="Verdana" d:LayoutOverrides="VerticalAlignment"  FontWeight="Bold"              
                
				/>

                <TextBlock x:Name="txtLabGrupoEconomico"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="15,45,0,0"
        			VerticalAlignment="Top" Width="auto" FontFamily="Verdana" 
        			Text="Grupo Econômico:" HorizontalAlignment="Left"	/>

                <TextBlock 
        			x:Name="txtGrupoEconomico" 
        			Text="Grupo Economico" 
        			FontSize="10"
        			Foreground="#FFFADE88"
        			Margin="111,45,0,0" 
        			VerticalAlignment="Top" Width="382" 
        			HorizontalAlignment="Left" FontFamily="Verdana" d:LayoutOverrides="VerticalAlignment"  FontWeight="Bold"               
				/>

                <TextBlock x:Name="Id" Width="1"  Visibility="Collapsed" HorizontalAlignment="Right" Margin="0,0,328,0" d:LayoutOverrides="Width"/>

                <TextBlock x:Name="txtLabParametro"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="0,27,570,0"
        			VerticalAlignment="Top" Width="auto" FontFamily="Verdana" 
        			Text="Parâmetro:" Height="14" HorizontalAlignment="Right"	/>

                <TextBlock
        			x:Name="txtParametro" 
        			Text="{Binding DscParametro}"
					FontWeight="ExtraBlack"
					Foreground="#FFFADE88" Margin="76,26,302,0" Height="14" VerticalAlignment="Top" 
				 />

                <TextBlock x:Name="txtLabValorParametro"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="0,27,223,0"
        			VerticalAlignment="Top" Width="auto" FontFamily="Verdana" HorizontalAlignment="Right" 
        			Text="Valor Atual:" Height="18" />

                <TextBlock x:Name="txtValorParametro" 
                    Height="18" HorizontalAlignment="Right" 
                    Margin="0,27,83,0" VerticalAlignment="Top" Width="133" 
                    TextWrapping="Wrap" Foreground="#FFFADE88" FontWeight="Bold" 
                    Text="Valor" FontSize="10"/>

                <CheckBox x:Name="chkDefault"
        			Height="20" 
        			Margin="303,115,267,0" 
                    VerticalAlignment="Top" 
        			Content="Default?"
                    ToolTipService.ToolTip="Desabilitar todas as vigencias deste parametro"
        			FontSize="10"
        			FontWeight="ExtraBold"
        			Foreground="#FFFADE88"
                    IsChecked="{Binding Path=IcDefault,  Converter={StaticResource ConverterReadonly}}"
                    DataContext="pDetalheContratoOperacao"
                    Checked="chkDefault_Checked"/>

                <Grid Margin="0,150,51,274" Background="White" Width="136" HorizontalAlignment="Right">
                    <inputToolkit1:NumericUpDown x:Name="valorParametroUD"
                            Value="{Binding Path=VlrParametro, Mode=TwoWay}"
			                VerticalAlignment="Top" Margin="0,-1,0,0" DecimalPlaces="2"
			                Increment="1.00" Maximum="9999999999999999" Minimum="0"
			                Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterNUD}}" 
                            Parsing="numUpDown_Parsing" Height="24" HorizontalAlignment="Right" Width="136"
                            DataContext="_pContrato"/>
                </Grid>

                <CheckBox x:Name="valorParametroCHK"
                        Height="19"
                        Width="16" 
                        HorizontalAlignment="Right"   
                        VerticalAlignment="Top" 
						IsChecked="{Binding Path=VlrParametro, Converter={StaticResource ConverterValueCHK}, Mode=TwoWay}"
						Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterCHK}}" 
                        Margin="0,150,171,0" IsEnabled="False"/>

                <TextBox x:Name="valorParametroTXT"
                        MaxLength="30" 
                        IsEnabled="False"
                        Text="{Binding Path=VlrParametro, Mode=TwoWay, Converter={StaticResource ConverterValueTxtBox}}"
						VerticalAlignment="Top" 
                        Margin="0,149,51,0"
						Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterTxtBox}}" 
                        Height="24"
                        Width="136"
                        HorizontalAlignment="Right"/>

                <basics:DatePicker 
                    Name="DtInicial" 
                    Height="24" 
                    HorizontalAlignment="Left" 
                    Margin="92,149,0,0" 
                    VerticalAlignment="Top" 
                    IsEnabled="False"/>

                <basics:DatePicker 
                    Name="DtTermino" 
                    Height="24" 
                    Margin="303,149,240,0" 
                    VerticalAlignment="Top" 
                    IsEnabled="False"/>

                <TextBlock 
                    Height="32" 
                    FontSize="10" 
                    Foreground="#FFF2ECDA" 
                    HorizontalAlignment="Left" 
                    Margin="18,145,0,0" 
                    VerticalAlignment="Top" 
                    Width="67" 
                    Text="Data Início Vigência" 
                    TextWrapping="Wrap" 
                    TextAlignment="Right"/>

                <TextBlock 
                    Height="32" 
                    FontSize="10" 
                    Foreground="#FFF2ECDA" 
                    Margin="219,145,0,0" 
                    VerticalAlignment="Top" 
                    Text="Data Término Vigência" 
                    TextWrapping="Wrap" 
                    HorizontalAlignment="Left" 
                    Width="73" 
                    TextAlignment="Right"/>

                <TextBlock 
                    FontSize="10" 
                    Foreground="#FFF2ECDA" 
                    TextAlignment="Right" 
                    Margin="409,153,191,274" 
                    Text="Valor" 
                    TextWrapping="Wrap" 
                    RenderTransformOrigin="1.196,0.5"/>

                <TextBlock x:Name="txtLabMotivo"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="48,115,0,312" 
                    Width="35" 
                    FontFamily="Verdana" 
                    HorizontalAlignment="Left" 
        			Text="Motivo" 
                    Height="20" 
                    RenderTransformOrigin="0.629,0.3" />

                <ComboBox x:Name="cboMotivos" 
                          Margin="91,112,0,0"
                          SelectedIndex="{Binding IdMotivo, Mode=TwoWay, Converter={StaticResource ConverterCboBox}}" 
                          Height="24" 
                          VerticalAlignment="Top" 
                          HorizontalAlignment="Left" 
                          Width="150" 
                          IsEnabled="False">

                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding DscMotivo, Mode=TwoWay}" />
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>

                </ComboBox>

                <TextBlock x:Name="txtLabJustificativa"
        			FontSize="10"
        			Foreground="#FFF2ECDA"
        			Margin="18,79,0,0" Width="65" FontFamily="Verdana" HorizontalAlignment="Left" 
        			Text="Justificativa" Height="20" VerticalAlignment="Top" TextAlignment="Right" />

                <TextBox x:Name="txtJustificativa" Height="24" Width="500" MaxLength="100" IsEnabled="False"
        			Text="{Binding DscJustificativa, Mode=TwoWay}" HorizontalAlignment="Left"   
        			VerticalAlignment="Top" Margin="91,75,0,0" d:LayoutOverrides="VerticalAlignment" />

                <data:DataGrid AutoGenerateColumns="False" Height="201" Margin="39,181,51,0" Background="#FF9AACB7" Name="grdDetalhesParametroContrato"  VerticalAlignment="Top" BorderBrush="{x:Null}" ItemsSource="{Binding}">
                    <data:DataGrid.Columns>
                        <data:DataGridTemplateColumn Header="Valor" Width="125">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Name="panelValor"  VerticalAlignment="Top" Margin="0" HorizontalAlignment="Right" Orientation="Horizontal">

                                        <inputToolkit1:NumericUpDown Name="nup" Width="150" IsEnabled="False"
                                            Value="{Binding Path=VlrParametro, Mode=TwoWay}" HorizontalAlignment="Center"   
                                                                 VerticalAlignment="Center" Margin="0" DecimalPlaces="2"
                                                                 Increment="1.00" Maximum="9999999999999999" Minimum="0"
                                            Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterNUD}}" Parsing="numUpDown_Parsing"
                                                          />

                                        <CheckBox Width="30" HorizontalAlignment="Center"   VerticalAlignment="Center" IsEnabled="False"
                                              IsChecked="{Binding Path=VlrParametro, Converter={StaticResource ConverterValueCHK}, Mode=TwoWay}"
                                              Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterCHK}}"/>

                                        <TextBox Name="txtBox" Width="100" 	MaxLength="30" IsReadOnly="True" 
											Text="{Binding Path=VlrParametro, Mode=TwoWay, Converter={StaticResource ConverterValueTxtBox}}" HorizontalAlignment="Center"   
                                                 VerticalAlignment="Center" Margin="0"
											     Visibility="{Binding Path=DscTipoCampo, Converter={StaticResource ConverterTxtBox}}" />

                                    </StackPanel>
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>
                        <data:DataGridTemplateColumn Header="Data Início Vigência" Width="130">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=DtInicio, Converter={StaticResource ConverterDateTime}}" HorizontalAlignment="Right" />
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>
                        <data:DataGridTemplateColumn Header="Data Fim Vigência" Width="130">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=DtTermino, Converter={StaticResource ConverterDateTime}}" HorizontalAlignment="Right"/>
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>

                        <data:DataGridTemplateColumn>
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="50" 
                                        Height="24"
    									HorizontalAlignment="Center" 
    									x:Name="btnEditar"
    									Click="btnEditar_Click">
                                        <StackPanel Name="detalhesParam"  VerticalAlignment="Center" Margin="0" HorizontalAlignment="Center" Orientation="Horizontal" Height="24">
                                            <Image Source="../image/edit.png" Width="15" HorizontalAlignment="Center" Margin="0,0,0,0" ToolTipService.ToolTip="Editar" />
                                        </StackPanel>
                                    </Button>
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>
                        <data:DataGridTemplateColumn>
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="50" 
                                        Height="24"
    									HorizontalAlignment="Center" 
    									x:Name="btnExcluir"
                                        Click="btnExcluir_Click"
                                        IsEnabled="{Binding ElementName=teste, Path=IsReadOnly}">
                                        <StackPanel Name="detalhesParam"  VerticalAlignment="Center" Margin="0" HorizontalAlignment="Center" Orientation="Horizontal" Height="24">
                                            <Image Source="../image/delete.png" Width="15" HorizontalAlignment="Center" Margin="0,0,0,0" ToolTipService.ToolTip="Excluir" />
                                        </StackPanel>
                                    </Button>
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>
                    </data:DataGrid.Columns>
                </data:DataGrid>

                <Grid Height="40" Margin="50,0,10,12" VerticalAlignment="Bottom" >

                    <Border Background="#FF9AACB7" CornerRadius="10" Margin="-29,0,28,0" />
                    <Button 
        				Margin="0,7,0,8" 
        				Width="120" 
        				HorizontalAlignment="Left" 
        				x:Name="btnNovo"
        				Click="btnNovo_Click" TabIndex="12">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../image/add.png" Height="16"/>
                            <TextBlock Text="Novo" Margin="10,2,0,0"/>
                        </StackPanel>
                    </Button>
                    <Button 
        				Margin="274,7,0,8" 
        				Width="120" 
        				HorizontalAlignment="Left" 
        				x:Name="btnCancelar"
        				Click="btnRejeitar_Click" TabIndex="12">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../image/eraser.png" Height="16" ToolTipService.ToolTip="Desabilita o parametro" />
                            <TextBlock Text="Cancelar" Margin="10,2,0,0"/>
                        </StackPanel>
                    </Button>
                    <Button 
        				Margin="138,7,324,8" 
        				x:Name="btnSalvar"    
        				Click="btnSalvar_Click" TabIndex="14" Width="120">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../image/save.png" Height="16" />
                            <TextBlock Text="Salvar" Margin="10,0,0,0"/>
                        </StackPanel>
                    </Button>
                    <Button 
        				x:Name="btnFechar"    
        				Click="btnFechar_Click" TabIndex="18" Margin="411,7,0,8" RenderTransformOrigin="0.455,-0.92" HorizontalAlignment="Left" Width="120">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../image/voltar.png" Height="34" Width="34" Margin="0,-18,0,0" 
        						Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Left" />
                            <TextBlock Text="Voltar" Margin="-8,0,0,0"/>
                        </StackPanel>
                    </Button>

                </Grid>
            </Grid>
        </Toolkit:BusyIndicator>
    </Grid>

</basics:ChildWindow>
    
    